Skip to content

Conversation

0xPoe
Copy link
Member

@0xPoe 0xPoe commented Oct 6, 2025

I think the order of the files in the versions table was broken, because Diesel runs migrations based on their creation time. Although we merged a325520a a long time ago, its migration file is newer than c977a31.
As a result, if you run the migrations locally, you’ll end up with a reordered schema file.

@0xPoe 0xPoe requested a review from a team October 6, 2025 21:03
Copy link
Member Author

@0xPoe 0xPoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to figure out how to prevent this kind of issue from happening again. It seems that our CI didn’t catch this issue.

@Turbo87
Copy link
Member

Turbo87 commented Oct 6, 2025

huh, that's a good catch. I'm not sure about the proposed solution though. on production the currently committed schema is probably correct since the migrations were applied in merge order. as long as we query by column name this order mismatch shouldn't matter too much, but if we query by column order this might be problematic.

@weiznich do you have any suggestions for situations like this? :)

@weiznich
Copy link
Contributor

weiznich commented Oct 7, 2025

There is a column_sorting option for diesel.toml files that could be used to address this. At currently has these options. I really need to get around documenting all the missing options on the web page…

That written: Diesel always requests columns by name in your select statement, so a different order in the table! definition shouldn't cause any issues as long as you don't rely on deserializing the data with #[derive(Queryable)] only (so no Selectable) and the fields in question all have the same type or as long as you don't write any custom select via QueryFragment and use * there. If you using Selectable (or the newer HasQuery derive) it should never be an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants